To improve the execution efficiency of a software program, the source codes of the software program may be transcompiled between different program languages. For example, the efficiency at which a JavaScript engine executes JavaScript language program codes is approximately a half of the efficiency at which the JavaScript engine executes native language program codes (e.g., program codes compiled by C or C++ languages). If the JavaScript language program codes are firstly transcompiled into the native language program codes before being executed by the JavaScript engine, the overall execution efficiency will be improved.
The JavaScript language program codes belong to dynamic language program codes involving dynamic typing and dynamic name binding. Dynamic typing means that the type of a variable in the dynamic language program code can be decided only when it is executed, while dynamic name binding means that the same function name in the dynamic language program code may be bound to different functions according to different execution conditions thereof. However, because of the aforesaid properties (i.e., dynamic typing and dynamic name binding), it is difficult to determine the variable type in the dynamic language program code during the process of transcompiling the dynamic language program code into a native language program code. The overall transcompiling efficiency (e.g., increasing the transcompilation time or decreasing the transcompilation accuracy) will then be affected.
Accordingly, it is important in the art to provide an effective variable inference method for use in the process of transcompiling dynamic language program codes into native language program codes.